package com.athuiju.fenxiaoback.service.impl;

import com.athuiju.fenxiaoback.entity.WmsWareSku;
import com.athuiju.fenxiaoback.entity.vo.SkuStockVo;
import com.athuiju.fenxiaoback.mapper.WmsWareSkuMapper;
import com.athuiju.fenxiaoback.service.WmsWareSkuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 商品库存 服务实现类
 * </p>
 *
 * @author athuiju
 * @since 2021-07-06
 */
@Service
public class WmsWareSkuServiceImpl extends ServiceImpl<WmsWareSkuMapper, WmsWareSku> implements WmsWareSkuService {



    @Override
    public List<SkuStockVo> getSkuHasStock(List<String> skuIds) {
        List<SkuStockVo> skuStockVos=new ArrayList<>();
        for (int i=0;i<skuIds.size();i++){
            SkuStockVo stockVo=new SkuStockVo();
            Long skuStock= this.baseMapper.getSkuStock(Long.parseLong( skuIds.get(i)));
            if (skuStock!=null){
                stockVo.setHasStock(true);
            }else{
                stockVo.setHasStock(false);
            }
            stockVo.setSkuId(Long.parseLong(skuIds.get(i)));
            skuStockVos.add(stockVo);
        }
        return skuStockVos;
    }
}
